package com.bdqn.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdqn.mapper.UserMapper;
import com.bdqn.pojo.User;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户业务逻辑层实现类（继承ServiceImpl类，MyBatis-Plus帮我们实现了常用CRUD接口的实现）
 *
 * @author LILIBO
 * @since 2023-12-08
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User login(String usrName, String usrPassword) {
        if (usrName == null || usrPassword == null) {
            return null;
        }
        User user = baseMapper.selectByUsrName(usrName);
        if (user == null) {
            return null;
        }
        if (usrPassword.equals(user.getUsrPassword())) {
            return user;
        }
        return null;
    }

    @Override
    public int addUser(User user) {
        return 0;
    }

    @Override
    public int deleteUser(Long usrId) {
        return 0;
    }

    @Override
    public int updateUser(User user) {
        return 0;
    }

    @Override
    public User getUser(Long usrId) {
        return baseMapper.selectById(usrId);
    }

    @Override
    public List<User> findAllUsers() {
        return baseMapper.selectList(null);
    }

}
